package com.example.algorithm.tree.binaryTree;


import com.example.algorithm.linear.queue.Queue;

public class Test {

    public static void main(String[] args) {

//        test();
//        test1();
//        test2();
//        test3();
//        test4();
        test5();
    }

    //层序遍历
    private static void test5() {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");
        //遍历
        System.out.println("最大深度是："+tree.maxDepth());
    }

    //层序遍历
    private static void test4() {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");
        //遍历
        Queue<String> keys = tree.layerErgodic();
        for (String key : keys) {
            System.out.println(key + ":" + tree.get(key));
        }
    }

    //后序遍历
    private static void test3() {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");
        //遍历
        Queue<String> keys = tree.afterErgodic();
        for (String key : keys) {
            System.out.println(key + ":" + tree.get(key));
        }
    }

    //中序遍历
    private static void test2() {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");
        //遍历
        Queue<String> keys = tree.midErgodic();
        for (String key : keys) {
            System.out.println(key + ":" + tree.get(key));
        }
    }

    //前序遍历
    private static void test1() {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");
        //遍历
        Queue<String> keys = tree.preErgodic();
        for (String key : keys) {
            System.out.print(key);
        }
    }

    private static void test() {
        BinaryTree<Integer, String> binaryTree = new BinaryTree<Integer, String>();

        binaryTree.put(5, "5");
        binaryTree.put(4, "4");
        binaryTree.put(6, "6");
        binaryTree.put(10, "10");
        binaryTree.put(8, "8");

        System.out.println(binaryTree.get(6));
        binaryTree.delete(6);
        System.out.println(binaryTree.get(6));
    }



}
